package com.hqyj.javaGraduation.hotel.controller;


import com.hqyj.javaGraduation.hotel.pojo.HotelSupplier;
import com.hqyj.javaGraduation.hotel.service.HotelSupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/hotel")
public class HotelSupplierController {

    @Autowired
    private HotelSupplierService hotelSupplierService;

    /**
     * 127.0.0.1:8080/hotel/addSupplier ---->get
     * {"supName":"城南阿三蔬菜商","supManager":"阿三","supIphone":"1763388","businessScope":"各种蔬菜贱卖","supPartner":"Yes"}
     * @param hotelSupplier
     * @return
     */
    @GetMapping(value = "/addSupplier")
    public HashMap<String,Object> addHotelSupplier( HotelSupplier hotelSupplier) {
        return hotelSupplierService.addHotelSupplier(hotelSupplier);
    }

    /**
     * 127.0.0.1:8080/hotel/yesOrNo ---->post
     * {"supName":"城南阿三蔬菜商","supManager":"阿三","supIphone":"1763388","businessScope":"各种蔬菜贱卖","supPartner":"Yes"}
     * @param hotelSupplier
     * @return
     */
    @PostMapping(value = "/yesOrNo")
    public HashMap<String,Object> yesOrNoSupplier( HotelSupplier hotelSupplier) {
        return hotelSupplierService.yesOrNoPartner(hotelSupplier);
    }

    /**
     * 127.0.0.1:8080/hotel/listAll ---->post
     * {"page":1,"row":2}
     * @param hotelSupplier
     * @return
     */
    @PostMapping(value = "/listAll")
    public HashMap<String, Object> listAll( HotelSupplier hotelSupplier) {
        return hotelSupplierService.listAll(hotelSupplier);
    }

    /**
     * 127.0.0.1:8080/hotel/updateSupplier ---->get
     *  {"supId":1,"supName":"城南阿三蔬菜商","supManager":"阿三","supIphone":"176338848","businessScope":"各种蔬菜贱卖","supPartner":"Yes"}
     * @param hotelSupplier
     * @return
     */
    @GetMapping(value = "/updateSupplier")
    public HashMap<String, Object> updateSupplier(HotelSupplier hotelSupplier) {
        return hotelSupplierService.update(hotelSupplier);
    }

    /**
     * 127.0.0.1:8080/hotel/supplier
     * @param id
     * @return
     */
    @DeleteMapping (value = "/supplier")
    public HashMap<String, Object> delSupplier( Integer id) {
        return hotelSupplierService.delSupplier(id);
    }


}
